<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<!-- 
  - Author(s): YANGZHOU
  - Date: 2013-03-01 17:43:27
  - Description:
-->
<%@page import="com.eos.foundation.eoscommon.ResourcesMessageUtil"%>
<%
	// 机构条件查询
	String orgConditionQuery = ResourcesMessageUtil.getI18nResourceMessage("orgConditionQuery"); 
	// 机构代码
	String orgCode = ResourcesMessageUtil.getI18nResourceMessage("orgCode"); 
	// 机构名称
	String orgName = ResourcesMessageUtil.getI18nResourceMessage("orgName"); 
	// 机构类型
	String orgType = ResourcesMessageUtil.getI18nResourceMessage("orgType"); 
 	// 机构等级
	String orgLevel = ResourcesMessageUtil.getI18nResourceMessage("orgLevel"); 
 	// 机构层级
	String orgDegree = ResourcesMessageUtil.getI18nResourceMessage("orgDegree"); 
 	// 机构状态
	String orgStatus = ResourcesMessageUtil.getI18nResourceMessage("orgStatus"); 
%>
<style>
#table1 .tit{
	height: 10px;
    line-height: 10px;
}
#table1 td{
	height: 10px;
    line-height: 10px;
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<%@include file="/coframe/tools/skins/common.jsp" %>
<link id="css_icon" rel="stylesheet" type="text/css" href="<%=contextPath%>/coframe/org/css/org.css"/>
<title>机构列表</title>
<body>
 <div class="search-condition">
   <div class="list">
	 <div id="form1" style="padding:5px;">
		<table style="width:100%;">
            <tr>
	            <td style="width:100%;">
	                <a class="nui-button" iconCls="icon-reload" onclick="reloadAll" id="all_btn">同步当前显示的全部机构</a>
	            	<a class="nui-button" iconCls="icon-reload" onclick="reloadSel" id="sel_btn">同步选中的机构</a>
	            </td>
            </tr>
        </table>
	</div>
  </div>
 </div>

	<div class="nui-fit" style="padding:5px;">
		<div id="datagrid1" class="nui-datagrid" style="width:100%;height:100%;parding:5px;"
		    url="org.gocom.components.coframe.org.synonyms.queryOrgForPortal.biz.ext" dataField="tree" sizeList="[10,20,50,100]" multiSelect="true">
		    <div property="columns">
		        <div type="checkcolumn"></div>
		        <div field="orgid" visible="false">机构ID</div>                
		        <div field="orgcode" width="120" headerAlign="center" >机构代码</div>    
		        <div field="orgname" width="120" headerAlign="center" >名称</div>    
		        <div field="orglevel" width="120" headerAlign="center" >等级</div>    
		        <div field="orgtype" width="120" headerAlign="center" renderer="renderOrgtype">机构类型</div>    
		        <div field="startdate" width="120" headerAlign="center" >生效日期</div>    
		        <div field="enddate" width="120" headerAlign="center" >失效日期</div>    
		    </div>
		</div>
	</div>

<script type="text/javascript">
	nui.parse();
	var form = new nui.Form("#form1");
	var grid = nui.get("datagrid1");
    grid.load();
	grid.sortBy("orgcode", "asc");
	
	//同步全部
	function reloadAll(){
		var json = nui.encode({datas:grid.getData()});
		$.ajax({
    		url: "org.gocom.components.coframe.org.synonyms.addOrUpdateOrganization.biz.ext",
    		type: 'POST',
    		data: json,
    		cache: false,
    		contentType:'text/json',
    		success: function (text) {
        		var returnJson = nui.decode(text);
				if(returnJson.resultStr == 'SUCCESS'){
					nui.alert("同步"+returnJson.index+"个机构","提示");
        		}
        		else{
        			nui.alert("同步失败","提示");
    			}
    		},
    		error: function () {
    		}
		});
	}

	//同步选择
	function reloadSel(){
		var rows = grid.getSelecteds();
		if(rows.length>0){
			var json = nui.encode({datas:rows});
			$.ajax({
	    		url: "org.gocom.components.coframe.org.synonyms.addOrUpdateOrganization.biz.ext",
	    		type: 'POST',
	    		data: json,
	    		cache: false,
	    		contentType:'text/json',
	    		success: function (text) {
	        		var returnJson = nui.decode(text);
					if(returnJson.resultStr == 'SUCCESS'){
						nui.alert("同步"+returnJson.index+"个机构","提示");
	        		}
	        		else{
	        			nui.alert("同步失败","提示");
	    			}
	    		},
	    		error: function () {
	    		}
			});
		}else{
			nui.alert("请选择待同步的机构数据！","提示");
		}
	}
	
	//机构类型数据字典
    function renderOrgtype(e) {
		return nui.getDictText("COF_ORGTYPE",e.row.orgtype);
	}
</script>

</body>
</html>